package com.yj.spider.config;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.dao.util.Daos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class NutzDaoConfig {

    @Autowired
    @Qualifier("spiderDataSource")
    DataSource dataSource;

    @Bean(name = "dao")
    public Dao getDao() throws Exception {
        Dao dao = new NutDao(dataSource);
        Daos.createTablesInPackage(dao, "com.yj.spider.Model", false);
        return dao;
    }


}